package it.megasoft78.turingmachine;

public class FileDialogItem implements Comparable<FileDialogItem> {
	private String name;
	private int iconResourceId;
	private String size;
	private String lastChange;

	public FileDialogItem(String name, int iconResourceId, String size, String lastChange) {
		super();
		this.name = name;
		this.iconResourceId = iconResourceId;
		this.size = size;
		this.lastChange = lastChange;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getIconResourceId() {
		return iconResourceId;
	}

	public void setIconResourceId(int iconResourceId) {
		this.iconResourceId = iconResourceId;
	}

	private int getIconOrder(int iconResourceId) {
		if (iconResourceId == R.drawable.folder)
			return 0;
		else
			return 1;
	}

	public String getSize() {
		return size;
	}

	public void setSize(String size) {
		this.size = size;
	}

	public String getLastChange() {
		return lastChange;
	}

	public void setLastChange(String lastChange) {
		this.lastChange = lastChange;
	}
	
	@Override
	public int compareTo(FileDialogItem another) {

		int iconOrder1 = this.getIconOrder(this.iconResourceId);
		int iconOrder2 = this.getIconOrder(another.iconResourceId);

		if (iconOrder1 == iconOrder2)
			return this.getName().compareTo(another.getName());
		else if (iconOrder1 < iconOrder2)
			return -1;
		else
			return 1;
	}
}
